var ser = "";
$(function(){
	
	$.ajax({  
         type : "post",  
         url : "priceTrendList",  
         async : false, 
         dataType : 'json',
         success : function(data){  
        	 var typeId = data.typeId;
        	 var type = data.type;
        	 var year = data.year;
        	 var shopTypeId;
             var se = [];
             var pr = [];
        	 for(var i in typeId){
        		 shopTypeId = typeId[i];
	        	
        		$.ajax({
        				type : "post",  
        		        url : "sPriceTrend",  
        		        async : false, 
        		        data : {"shopTypeId": shopTypeId},
        		        dataType : 'json',
        		        success : function(datas){
        		       	var typeName = datas.type; 
        		       	var price = datas.price;
        		    	pr.push(price) 
        		        var ser={
    		        		name: typeName,
    		        		type:'line',
    		        		stack:'价钱',
    		        		data:price
        		         };
    		 
    		       		se.push(ser);
    		        }
    		        
        		       
        		        
        			});
        		
		     }
        	 console.log(se);
        	// 基于准备好的dom，初始化echarts实例
        	    var myChart = echarts.init(document.getElementById('main'));
        	    data2 =  data.type;
        	    // 指定图表的配置项和数据
        	    option = {
        		    tooltip : {
        		        trigger: 'axis'
        		    },
        		    legend: {
        		   //     data:['中国绘画','书法篆刻','西画雕塑','古瓷杂项','当代工艺']
        		    	data: type
        		    },
        		    toolbox: {
        		        show : true,
        		        feature : {
        		          //  mark : {show: true},
        		            dataView : {show: true, readOnly: false},
        		            magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
        		            restore : {show: true},
        		            saveAsImage : {show: true}
        		        }
        		    },
        		    calculable : true,
        		    xAxis : [
        		        {
        		            type : 'category',
        		            boundaryGap : false,
        		       //     data : ['2012','2013','2014','2015','2016','2017','2018']
        		            data : year
        		        }
        		    ],
        		    yAxis : [
        		        {
        		            type : 'value'
        		        }
        		    ],
        		    series : 
        		          se
        		};
        	                
        	    // 使用刚指定的配置项和数据显示图表。
        	    myChart.setOption(option);
        	 
         }  
    });
	
	
}); 


		